﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HandyControl.Interactivity;
using IntoStationSystem.Global;
using IntoStationSystem.ViewModels;

namespace IntoStationSystem.Views
{
    /// <summary>
    /// Login.xaml 的交互逻辑
    /// </summary>
    public partial class LoginView : UserControl
    {
        LoginViewModel vm => Locator.Instance.LoginVM;
        public LoginView()
        {
            InitializeComponent();
            this.DataContext = vm;
             
        }

        private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
        {
            vm.Password = (sender as PasswordBox).Password;
        }

        private void Login_Click(object sender, RoutedEventArgs e)
        {
            if (vm.Login())
            {
                vm.Password = string.Empty;
                Window.GetWindow(this).Close();
            }
        }

        private void PasswordBox_GotFocus(object sender, RoutedEventArgs e)
        {
            Funcs.ShowSoftKeyboard();
        }
    }
}
